Template Creation through JSON
Template creation through JSON
A data template is how you tell YoBulk data engine ,what you want your data to look like.
YoBulk enables any developer to create a template by importing a JSON schema.
YoBulk editors supports AJV schema type.https://ajv.js.org/json-schema.html
Sample YoBulk Schema
{
"type":"object",
"properties":{
"id":{
"type":"integer",
},
"first_name":{
"type":"string",
"format": "first_name",
"validate": "(x) => {\r\n let regex = new RegExp(\"([a-z][a-zA-Z]*)\");\r\n return regex.test(x);\r\n }"
},
"email":{
"type":"string",
"format":"email",
"minLength":1
},
"date":{
"type":"string",
"format":"custom-date-time",
"minLength":1
},
"status": {
"type": "string",
"format":"custom-boolean",
},
},
"required":[
"id",
"first_name",
"email",
"custom-date-time",
"status"
],
"errorMessage":{
"properties":{
"first_name":"Only string(With character A-Z) type is accepted.",
"id":"Only valid interge format type is accepted",
"email":"Only Valid email ID format is accepted",
"date":"Only valid date format is accepted",
"status":"Only boolean is accepted"
}
}
}
YoBulk custom function fields:
YoBulk has added a custom field named as validate
which can be used to pass any javascript validation
function as string.
- Pre-requisites
- YoBulk requires the javascript function you provide to be a string
- it will also need to be JSON escaped.please use
https://www.freeformatter.com/json-escape.html
to get the interface JSON escaped
YoBulk custom date and boolean field:
YoBulk enables developer to validate all date types by adding custom fields like custom-date-time
and custom-boolean
Example:
"date":{
"type":"string",
"format":"custom-date-time",
"minLength":1
},
YoBulk Regex field
YoBulk gives a provision to add any regex validation against any specific field.
A regex can be added using Pattern
keyword.
Example: Regex to validate email IDs with yahoo and gmail domain name.
"email":{
"type":"string",
"format":"email",
"pattern":"^((?!(gmail|yahoo)\..$).)$",
"minLength":1
},